#include <iostream>
#include <string>
#include <cstring>
using namespace std;

int n, c, W;
int dis[1010], sum[1010];
int f[1010][1010][2];

int count(int l, int r, int i, int j)
{
    return (sum[l] + sum[n] - sum[r - 1]) * (dis[j] - dis[i]); //求出浪费的电力
}

int main()
{
    cin >> n >> c;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> dis[i] >> sum[i];
        sum[i] += sum[i - 1];
    }
    memset(f, 0x3f, sizeof(f));  
    f[c][c][1] = f[c][c][0] = 0;
    for (int r = c; r <= n; ++r)
    {
        for (int l = r - 1; l; --l)
        {
            int k1, k2;

            k1 = f[l + 1][r][0] + count(l, r + 1, l, l + 1);
            k2 = f[l + 1][r][1] + count(l, r + 1, l, r);
            f[l][r][0] = min(k1, k2);

            k1 = f[l][r - 1][0] + count(l - 1, r, l, r);
            k2 = f[l][r - 1][1] + count(l - 1, r, r - 1, r);
            f[l][r][1] = min(k1, k2);
        }
    }
    ans = min(f[1][n][1], f[1][n][0]);
    cout << ans <<endl;
    //system("pause");
    return 0;
}